package com.mes.cloud.threadlocal;

import java.util.HashMap;
import java.util.Map;

public class BaseContextHandler {
    public static InheritableThreadLocal<Map<String, Object>> threadLocal = new InheritableThreadLocal();

    public BaseContextHandler() {
    }

    public static void set(String key, Object value) {
        Map<String, Object> map;
        if ((map = (Map) threadLocal.get()) == null) {
            map = new HashMap();
            threadLocal.set(map);
        }

        ((Map) map).put(key, value);
    }

    public static Object get(String key) {
        Map<String, Object> map;
        if ((map = (Map) threadLocal.get()) == null) {
            map = new HashMap();
            threadLocal.set(map);
        }

        return ((Map) map).get(key);
    }

    public static void remove() {
        threadLocal.remove();
    }
}
